<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <h1>简单计算器</h1>
        <div>
            <span>数值a:</span>
            <span>
                <input type="text" v-model = 'a'>
            </span>
        </div>
        <div>
            <span>数值b:</span>
            <span>
                <input type="text" v-model = 'b'>
            </span>
        </div>
        <div>
            <button v-on:click = 'handle'>计算</button>
        </div>
        <div>
            <span>计算结果</span>
            <span v-text='result'></span>
        </div>
    </div>
    <script type="text/javascript">
    const vm = new Vue({
        el:'#app',
        data:{
            a:'',
            b:'',
            result:''
        },
        methods:{
            handle:function(){
                // 实现计算逻辑，只用对数据进行处理
                this.result = parseInt(this.a) + parseInt(this.b)
                console.log(this.result)
            }
        }
    })
    </script>
</body>
</html>